package com.flyoil.petromp.mvp_m.MatterModel;

import com.flyoil.petromp.Constant.ConstantNetworkCode;
import com.flyoil.petromp.apiservice.OnObserverRetrofitResetCallBack;
import com.flyoil.petromp.base.BaseEntity;
import com.flyoil.petromp.entity.entity_matter.MatterEntity;
import com.flyoil.petromp.base.BaseModel;
import com.flyoil.petromp.entity.entity_matter.MatterNetworkEntity;
import com.flyoil.petromp.mvp_p.Listener.OnPresenterListener;
import com.flyoil.petromp.utils.OrderUtl.OrderListUtil;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * Created by songzhiyin on 2017/10/31.
 * 已办事项列表的数据处理类
 */

public class MatterUnFinishListModel implements BaseModel {


    @Override
    public void loadNetworkData(Map<String, Object> map, final OnPresenterListener listener) {
        httpModel.getMatterUnFinishList(map, new OnObserverRetrofitResetCallBack<BaseEntity>() {
            @Override
            public void onSuccess(BaseEntity model) {
                super.onSuccess(model);
                if (model.getCode() != ConstantNetworkCode.SuccedCode) {
                    listener.onsucced(null);
                    return;
                }
                MatterNetworkEntity entity = null;
                if (model instanceof MatterNetworkEntity) {
                    entity = (MatterNetworkEntity) model;
                }
                if (entity != null && entity.getData() != null && entity.getData().getList() != null) {
                    listener.onsucced(entity.getData().getList());
                } else {
                    listener.onsucced(null);
                }
            }

            @Override
            public void onFailure(String msg) {
                listener.onsucced(null);
            }
        });

    }
}
